package com.smh.a04UDPDemo3;

import java.io.IOException;
import java.net.*;

public class SendMessageDemo1 {
    public static void main(String[] args) throws IOException {

        DatagramSocket ds = new DatagramSocket();

        String s = "12312313";
        byte[] bytes = s.getBytes();
        //一旦将其改为255.255.255.255,就是广播,向局域网里面所有设备发送数据.
        InetAddress address = InetAddress.getByName("224.0.0.1");
        int port = 10000;
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length, address, port);

        ds.send(dp);
        ds.close();

    }
}
